package com.septimus.portal.service;

import org.apache.log4j.Logger;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import com.septimus.portal.model.Message;

@Stateless
public class MessagePost {

	@Inject
	private Logger log;

	@Inject
	private EntityManager em;

	@Inject
	private Event<Message> messageEventSrc;

	public void send(Message message) throws Exception {
		log.info("\n\nRegistering " + message.getTitle());
		em.persist(message);
		messageEventSrc.fire(message);
	}
}
